package cn.dankal.flyaudio.activity.search.searchfragment;

import api.ActivityServiceFactory;
import cn.dankal.basiclib.base.BasePresenterImp;
import cn.dankal.basiclib.rx.AbstractDialogSubscriber;
import cn.dankal.business.pojo.BaseBeanList;
import cn.dankal.business.pojo.HotSearchBean;

/**
 * @author ricky
 * @date 2018/8/15 0015
 */

public class SearchFPresenter extends BasePresenterImp<SearchFContract.SearchFView> implements SearchFContract.SearchFPresenter{

    /**
     * 获取热门搜索词
     */
    @Override
    public void obtainHotSearch() {
        ActivityServiceFactory.hot_search_list("1","100").subscribe(new AbstractDialogSubscriber<BaseBeanList<HotSearchBean>>(mView) {

            @Override
            public void onNext(BaseBeanList<HotSearchBean> hotSearchBeanBaseBeanList) {
                if (mView!=null) {
                    mView.obtainHotSearchSuccess(hotSearchBeanBaseBeanList);
                    mView.dismissLoadingDialog();
                }
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
                if (mView!=null)
                    mView.dismissLoadingDialog();
            }
        });

    }

}
